/*
 *  This file was originally created by Ireneusz Grala on 29th of December 2010
 *  e-mail: ireneusz.grala@wp.pl
 *  
 */

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using IRQ.BaseFunctions;

namespace SimpleGPSApp.Base
{
    public class Root
    {
        public static string ErrorLogFileName = ApplicationHelper.StartupPath + @"\errorLog.txt";

        public static string PositionLogFileName =ApplicationHelper.StartupPath +
                   Path.DirectorySeparatorChar + @"\data\" +
                   DateTime.Now.ToString("yyyyMMddHHmmss") + "positions.txt";

        public static string ConfigurationFile = ApplicationHelper.StartupPath + "\\application.xml";

        public static string StatisticsFile = ApplicationHelper.StartupPath + @"\statistics.xml";

        public static Settings ApplicationSettings = new Settings();

        public static Statistics Statistics = new Statistics();

        public static void StartupSettings()
        {
            string dataDirectory = ApplicationHelper.StartupPath + Path.DirectorySeparatorChar + "data";

            if (!Directory.Exists(dataDirectory))
            {
                try
                {
                    Directory.CreateDirectory(dataDirectory);
                }
                catch (Exception e)
                {
                    PositionLogFileName = ApplicationHelper.StartupPath + Path.DirectorySeparatorChar + 
                        Path.GetFileName(PositionLogFileName);
                    
                    IRQ.BaseFunctions.ErrorLog.WriteError(Root.ErrorLogFileName,
                    "LogPositionOnServer2: " + e.ToString());
                }
            }
        }
    }

    public enum LogType : int
    {
        File,
        Server,
        FileAndServer,
        Off,
    }
}
